package com.gitee.huxing.framework.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.time.LocalDateTime;

/**
 * @Description: 上下文
 * @ProjectName: SpringCloudLearning
 * @Package: com.huxing.framework.utils
 * @ClassName: ApplicationContextHelper
 * @Author: huxing
 * Date: 2021-05-24
 * Time: 10:57
 */
@SuppressWarnings("all")
@Slf4j
public class ApplicationContextHelper implements ApplicationContextAware {

    private static ApplicationContext ctx;

    @Override
    synchronized public void setApplicationContext(ApplicationContext appContext) throws BeansException {
        log.info("预加载容器类:  {}" , LocalDateTime.now());
        ctx = appContext;
    }

    public static ApplicationContext getApplicationContext() {
        return ctx;
    }
}
